package objectstream;

import java.io.Serializable;
import java.util.Objects;

/**
 * Created by 5406160@qq.com on LiBoWen 李博闻.
 *
 * @ClassName : Student
 * @Author : 54061
 * @Date: 2022/2/14 17:48
 */
/*
 1 私有所有成员变量
    2 自动生成无参构造
    3 自动生成全参构造
    4 自动生成getter and setter方法
    5 自动生成equals and hashCode方法
    6 自动生成toString方法
    7 实现序列化接口 Serializable
    8 自动生成序列化id
    //对象的行为 根据需求编写
 */
public class Student  implements Serializable{
    private static final long serialVersionUID = 8729402280477774377L;
    private String sid;
    private String name;
    private int age;//String
    private String address;

    public Student() {
    }

    public Student(String sid, String name, int age, String address) {
        this.sid = sid;
        this.name = name;
        this.age = age;
        this.address = address;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return age == student.age &&
                Objects.equals(sid, student.sid) &&
                Objects.equals(name, student.name) &&
                Objects.equals(address, student.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sid, name, age, address);
    }

    @Override
    public String toString() {
        return "Student{" +
                "sid='" + sid + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", address='" + address + '\'' +
                '}';
    }
}
